home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d8 / toes114g.arc / TOESDIAL.SLT < prev    next >
Text File  |  1991-05-21  |  11KB  |  275 lines

  1. /////////////////////////////   TOESDIAL.SLT    //////////////////////////////////
  2. //                      Version 1.14 - April 1991
  3. // Written by Ken Ironside of 5:491/1
  4. // Maintained by Allan Marillier of 5:491/1
  5. //
  6. // Golden City Fido (GCF) log-on script - OPUS specific
  7. // PLEASE - read (or at least skim) the docs. There are no user configurable
  8. //          variables, or anything in this file any more.
  9.  
  10. // Modifications by Allan Marillier of 5:491/1 - September/October 1990
  11. // More mods - Allan Marillier - February 1991
  12. //
  13. // Before using this script for the first time, or when you make a change,
  14. // type 'cs toesdial' at the DOS prompt to compile the script for use by Telix.
  15. //
  16. // You must install this logon script and a password in your dialing
  17. // directory in Telix. This script will pick up the password from there.
  18. //
  19.  
  20. // Modifications by Allan Marillier of 5:491/1, September/October 1990
  21. //           Modified because Dave now uses YMS, and requires an extra
  22. //           Enter to get in ... (YMS being the mail checker Your Mail Sir)
  23. // Also added code to check for BBS requesting a new password. If required,
  24. // then check for file password.new. Pass that up twice to change the password
  25. // on the BBS, then write out a message to the cap file. This is for BBS's
  26. // where the sysop has decided to implement a facility to force passwords
  27. // to change at whatever intervals.
  28. // Feb 1991 - added code to set log file correctly, same as in TOES.SLT
  29. //   in case of messages when setting a new password. This was a result of
  30. //   the change in log file naming convention.
  31.  
  32. // Modified again in April 1991 to read the user name from the configuration
  33. // file TOES.CNF
  34. //
  35. /////////////////////////////////////////////////////////////////////////////
  36. /////////////////////////////////////////////////////////////////////////////
  37.  
  38. int pass_word_len = 6;  // Golden City BBS wants 6 characters
  39. str date_name[8]; // hold dated name of log file
  40. str user_name[60];
  41. str user_password[50];
  42. str i_send_password[1];
  43. /////////////////////////////////////////////////////////////////////////////
  44.  
  45. main()
  46.  
  47. {
  48.   int stat;
  49.   int t1, t2, t3, t4;
  50.   int tmark;
  51.  
  52.   // following code added to prepare for opening log file to
  53.   //       write report on password change, if required
  54.   int f;  // general purpose file handle
  55.   str new_word[20];   // variable to hold the password
  56.   str temp_word[80];   // variable to hold the word read from password.new
  57.  
  58.   str date_string[16] = "";    // To hold the date string
  59.   str log_file[4] = ".LOG";    // The shell of the capture file name
  60.   int temp_num;                // Temp numeric variable
  61.  
  62.   // open the TOES.CNF file, and read the user name. Skip past color, and
  63.   // dial_str
  64.   temp_num = fopen("TOES.CNF","r");
  65.   temp_word = "";
  66.   fgets(temp_word,3,temp_num);  // read color
  67.   temp_word = "";
  68.   fgets(temp_word,60,temp_num);  // read dial_str
  69.   user_name = "";
  70.   fgets(temp_word,80,temp_num);  // read user name
  71.   if (strlen(temp_word) > 5)
  72.     user_name = temp_word;
  73.   else
  74.   {
  75.     clear_scr();
  76.     prints("WARNING ! The name is less than 5 characters. This is not acceptable !");
  77.     prints("Press any key to abort this script ....");
  78.     temp_num = inkeyw();
  79.     exittelix();
  80.   }
  81.   strcat(user_name,";y");       // concatenate ; and y
  82.   temp_word = "";
  83.   fgets(temp_word,80,temp_num);  // mail packet
  84.   temp_word = "";
  85.   fgets(temp_word,80,temp_num);  // reply packet
  86.   temp_word = "";
  87.   fgets(temp_word,80,temp_num);  // reply dir
  88.   temp_word = "";
  89.   fgets(temp_word,80,temp_num);  // mail dir
  90.   temp_word = "";
  91.   fgets(temp_word,3,temp_num);  // make date packet
  92.   temp_word = "";
  93.   fgets(temp_word,3,temp_num);  // zmodem_protocol
  94.   temp_word = "";
  95.   fgets(temp_word,3,temp_num);  // auto_zap_opx
  96.   temp_word = "";
  97.   fgets(temp_word,3,temp_num);  // i_send_password
  98.   if (temp_word == "Y")
  99.     i_send_password = "Y";
  100.   else
  101.     i_send_password = "N";
  102.   temp_word = "";
  103.   fgets(temp_word,53,temp_num);  // user_password
  104.   user_password = temp_word;
  105.   fclose(temp_num);
  106.  
  107.   set_date_name();
  108.   strcat(date_string,date_name);
  109.   strcat(date_string,log_file);
  110.  
  111.   alarm (1);
  112.  
  113.   if (not _entry_pass && i_send_password == "N")                // no password, so didn't recog. board
  114.   {
  115.     prints ("Sorry, I don't know the password for this BBS!");
  116.     return;
  117.   }
  118.  
  119.   cputs ("^M");                        // Dave's board seems to need a
  120.   cputs ("^M");                        // few CR's to get going!
  121.  
  122.   t1 = track ("Please press your Escape key to enter the BBS, or wait 30 seconds....", 0);
  123.   t2 = track ("What is your FIRST name: ", 0);
  124.   t3 = track ("More [Y,n,=]? ");
  125.   t4 = track ("Enter a NEW Password");
  126.  
  127.   tmark = timer_start (600);            // wait up to 1 minutes for login
  128.  
  129.   while (not time_up (tmark))
  130.   {
  131.     terminal();                         // let Telix process any chars and keys
  132.  
  133.     stat = track_hit (0);               // see which (if any) track was hit
  134.  
  135.     if (stat == t1)                     // We'll need to wake up the BBS
  136.     {
  137.       cputs ("^[");                     // send Esc
  138.     }
  139.     else if (stat == t2)                // send name
  140.     {
  141.       // cputs (user_first_name);
  142.       cputs(user_name);
  143.       cputs ("^M");
  144.       break;                            // Exit the loop
  145.     }
  146.   }
  147.  
  148.   track_free (0);                      // Free up all track channels
  149.  
  150.   waitfor ("Password: ",30);
  151.   {
  152.     if (i_send_password == "Y")
  153.       cputs(user_password);
  154.     else
  155.       cputs (_entry_pass);
  156.     cputs ("^M");
  157.   }
  158.  
  159.   // added code here to check if a new password is required.
  160.   // If so - check for file password.new - read the new word, pass
  161.   // it up, pass it again for verification, then write a message to
  162.   // the cap file. Rename the file password.new to force the user
  163.   // to create another for the next time
  164.  
  165.   stat = track_hit(0);
  166.   if (stat == t4)  // it's time to change the password ...
  167.   {
  168.     if (filefind("password.new",pass_word_len) != 0) // check for normal, hidden, system
  169.     {
  170.       f = fopen("password.new","r");   // open the file if it exists
  171.       fgets(temp_word,80,f);  // read into new_word, up to 80 chars
  172.       fclose(f);   // close the file
  173.  
  174.       temp_num = strpos(temp_word," ",0);   // check for spaces
  175.       if (temp_num == -1)
  176.         temp_num = strlen(temp_word);   // cater for no spaces in the line
  177.       substr(temp_word,0,temp_num,new_word); // extract first word only
  178.       if (strlen(new_word) < 6)
  179.       {
  180.         // length of word is not acceptable
  181.         // write message to the log file, then exit the script
  182.         f = fopen(date_string,"a");    // re-open the log file for appending
  183.         fputs("^M^J",f);
  184.         fputs("************************************************************^M^J",f);
  185.         fputs("WARNING ! The BBS expects you to enter a new PASSWORD^M^J",f);
  186.         fputs("The file named PASSWORD.NEW was found. The length of the word^M^J",f);
  187.         fputs("  in this file was too short. The BBS expects a minimum of 6^M^J",f);
  188.         fputs("  chars as a NEW password. Please correct this file, and re-run^M^J",f);
  189.         fputs("  this script, OR connect to the BBS manually, and change the^M^J",f);
  190.         fputs("  password yourself.^M^J",f);
  191.         fputs("************************************************************^M^J",f);
  192.         fclose(f);
  193.         exittelix(0,1);  // hang up, set error level to 0 and quit telix
  194.       }
  195.       // assume if we got here, word length is OK -
  196.       // write message to the log file, then exit the script
  197.       frename("password.new","password.old"); // rename to prevent further use
  198.       f = fopen(date_string,"a");    // re-open the log file for appending
  199.       fputs("^M^J",f);
  200.       fputs("************************************************************^M^J",f);
  201.       fputs("WARNING ! The BBS expects you to enter a new PASSWORD^M^J",f);
  202.       fputs("          the word * ",f);
  203.       fputs(new_word,f);
  204.       fputs(" * was found to be acceptable.^M^J",f);
  205.       fputs(" PLEASE NOTE ! check this log to see if the password was accepted.^M^J",f);
  206.       fputs(" If it was, you must modify your Telix dialling directory accordingly.^M^J",f);
  207.       fputs("************************************************************^M^J",f);
  208.  
  209.       cputs (new_word);    // now send the new password
  210.       cputs ("^M");
  211.  
  212.       waitfor ("Re-Enter Password for verification",30);  // wait until verify
  213.       {
  214.         cputs (new_word);    // and send the password again to verify ...
  215.         cputs ("^M");
  216.       }
  217.     }
  218.     else  // the password.new file doesn't exist
  219.     {
  220.       // write message to the log file, then exit the script
  221.       f = fopen(date_string,"a");    // re-open the log file for appending
  222.       fputs("^M^J",f);
  223.       fputs("************************************************************^M^J",f);
  224.       fputs("WARNING ! The BBS expects you to enter a new PASSWORD^M^J",f);
  225.       fputs("No file named PASSWORD.NEW was found. If a file of this name^M^J",f);
  226.       fputs("  had existed, with a single word in it, this would have been^M^J",f);
  227.       fputs("  used as a NEW password. Please create this file, and re-run^M^J",f);
  228.       fputs("  this script, OR connect to the BBS manually, and change the^M^J",f);
  229.       fputs("  password yourself.^M^J",f);
  230.       fputs("************************************************************^M^J",f);
  231.       fclose(f);
  232.       exittelix(0,1);  // hang up, set error level to 0 and quit telix
  233.     }
  234.     // end of code to check if new password is required
  235.   } // end of checking if new password is required by BBS
  236.  
  237.   waitfor ("Press ENTER to continue ",30);   // this is the initial one
  238.   cputs("^M");
  239.  
  240.   // added the following lines to get around the YMS program
  241.   // reporting on mail in areas 1 and 3, then pausing
  242.   if (waitfor ("Press ENTER to continue ",30))
  243.     cputs("^M");
  244.  
  245.   // now add another one to get past the message if subscriptions are due
  246.   // if (waitfor ("Press ENTER to continue ",15))
  247.   //   cputs("^M");
  248.  
  249.   if (time_up (tmark))
  250.     prints ("Logon failed!");
  251.  
  252.   timer_free (tmark);                   // free timer channel
  253. }
  254. /////////////////////////////////////////////////////////////////////////////
  255. set_date_name()
  256. // function to read date and set variable date_name in YYMMDD format
  257. {
  258.   str dat[4];           // temp to hold dates
  259.   int temp;            // Temp variable to hold the numeric date value
  260.  
  261.   temp = curtime();
  262.   itos(tyear(temp),dat);
  263.   strcat (date_name,dat);
  264.   delchrs(date_name,0,2);   // remove the century digits
  265.   itos(tmonth(temp),dat);
  266.   if (tmonth(temp) < 10)  // precede 1 to 9 with 0
  267.     strcat(date_name,"0");
  268.   strcat (date_name,dat);
  269.   itos(tday(temp),dat);
  270.   if (tday(temp) < 10)  // precede 1 to 9 with 0
  271.     strcat(date_name,"0");
  272.   strcat (date_name,dat);
  273. }   // end set_date_name
  274. /////////////////////////////////////////////////////////////////////////////
  275.